
test-convert1.o:     file format elf32-littlearm


Disassembly of section .text:

00000000 <main>:
    char word;
	int num;
};  
  
int main()  
{  
   0:	e92d4800 	push	{fp, lr}
   4:	e28db004 	add	fp, sp, #4
   8:	e24dd020 	sub	sp, sp, #32
    struct A1 x = {10, 'A'};
   c:	e59f2088 	ldr	r2, [pc, #136]	; 9c <main+0x9c>
  10:	e24b3010 	sub	r3, fp, #16
  14:	e8920003 	ldm	r2, {r0, r1}
  18:	e8830003 	stm	r3, {r0, r1}
	struct A2 y = {'A', 10};
  1c:	e59f207c 	ldr	r2, [pc, #124]	; a0 <main+0xa0>
  20:	e24b3018 	sub	r3, fp, #24
  24:	e8920003 	ldm	r2, {r0, r1}
  28:	e8830003 	stm	r3, {r0, r1}

	/* 第一种方法 */
	//w.word = ((struct A2)x).a;	// error: conversion to non-scalar type requested

	/* 第二方法 */
	p = (struct A2 *)&x;
  2c:	e24b3010 	sub	r3, fp, #16
  30:	e50b3008 	str	r3, [fp, #-8]
	w.word = p->word;
  34:	e51b3008 	ldr	r3, [fp, #-8]
  38:	e5d33000 	ldrb	r3, [r3]
  3c:	e54b3020 	strb	r3, [fp, #-32]	; 0xffffffe0

	printf("%d\n", w.word);		// 这种强制类型转换,把x当A2类型变量使用就通过这个p指针    output: 10
  40:	e55b3020 	ldrb	r3, [fp, #-32]	; 0xffffffe0
  44:	e1a01003 	mov	r1, r3
  48:	e59f0054 	ldr	r0, [pc, #84]	; a4 <main+0xa4>
  4c:	ebfffffe 	bl	0 <printf>


	x.num = 1000;
  50:	e3a03ffa 	mov	r3, #1000	; 0x3e8
  54:	e50b3010 	str	r3, [fp, #-16]
	x.word = 'a';
  58:	e3a03061 	mov	r3, #97	; 0x61
  5c:	e54b300c 	strb	r3, [fp, #-12]

	y.word = 'a';
  60:	e3a03061 	mov	r3, #97	; 0x61
  64:	e54b3018 	strb	r3, [fp, #-24]	; 0xffffffe8
	y.num = 1000;
  68:	e3a03ffa 	mov	r3, #1000	; 0x3e8
  6c:	e50b3014 	str	r3, [fp, #-20]	; 0xffffffec
	
	//p = (struct A2 *)&x;
	w.word = p->word;
  70:	e51b3008 	ldr	r3, [fp, #-8]
  74:	e5d33000 	ldrb	r3, [r3]
  78:	e54b3020 	strb	r3, [fp, #-32]	; 0xffffffe0

	printf("%d\n", w.word);		// output : -24 ; 因A2第一成员为char, 当大于255时，越界。
  7c:	e55b3020 	ldrb	r3, [fp, #-32]	; 0xffffffe0
  80:	e1a01003 	mov	r1, r3
  84:	e59f0018 	ldr	r0, [pc, #24]	; a4 <main+0xa4>
  88:	ebfffffe 	bl	0 <printf>


	return 0;
  8c:	e3a03000 	mov	r3, #0
}																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																									  
  90:	e1a00003 	mov	r0, r3
  94:	e24bd004 	sub	sp, fp, #4
  98:	e8bd8800 	pop	{fp, pc}
  9c:	00000004 	.word	0x00000004
  a0:	0000000c 	.word	0x0000000c
  a4:	00000000 	.word	0x00000000
